/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Interfaz.java
 *
 * Created on 6/06/2010, 04:42:10 PM
 */

package mx.unam.ia.grafica;

import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import mx.unam.ia.algoritmos.*;
import mx.unam.ia.estructuras.*;

/**
 *
 * @author Jorge A Hernandez
 */
public class Interfaz extends javax.swing.JFrame {

    /** Creates new form Interfaz */
    public Interfaz() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        textField3 = new java.awt.TextField();
        label3 = new java.awt.Label();
        label2 = new java.awt.Label();
        label1 = new java.awt.Label();
        textField1 = new java.awt.TextField();
        textField2 = new java.awt.TextField();
        jPanel3 = new javax.swing.JPanel();
        label8 = new java.awt.Label();
        label9 = new java.awt.Label();
        label7 = new java.awt.Label();
        label5 = new java.awt.Label();
        label4 = new java.awt.Label();
        textField4 = new java.awt.TextField();
        textField6 = new java.awt.TextField();
        textField7 = new java.awt.TextField();
        textField8 = new java.awt.TextField();
        textField5 = new java.awt.TextField();
        jSpinner1 = new javax.swing.JSpinner();
        label12 = new java.awt.Label();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JSeparator();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Algoritmos Genéticos");
        setResizable(false);

        jButton1.setText("Analizar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Limpiar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("Salir");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        jLabel1.setText("Resultados:");

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Cromosoma", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N

        textField3.setText("0.95");

        label3.setText("Probabilidad Operación:");

        label2.setText("Terminales:");

        label1.setText("Cabezas:");

        textField1.setText("15");

        textField2.setText("2");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(textField3, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(22, 22, 22)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(textField2, javax.swing.GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)
                            .addComponent(textField1, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(15, Short.MAX_VALUE))))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20)
                .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(49, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Algoritmo Genético", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N

        label8.setText("% Elitista:");

        label9.setText("Mutación:");

        label7.setText("Cruza:");

        label5.setText("Población:");

        label4.setText("Generaciones:");

        textField4.setText("50");

        textField6.setText("25");

        textField7.setText("0.5");

        textField8.setText("0.2");

        textField5.setText("15");

        jSpinner1.setValue(new Integer(10));

        label12.setText("Repeticiones:");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(19, 19, 19)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(textField6, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(textField4, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(textField7, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(textField8, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(textField5, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(35, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(textField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(textField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(76, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addGap(99, 99, 99)
                .addComponent(jButton2)
                .addGap(96, 96, 96)
                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(83, 83, 83))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 513, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(60, 60, 60)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(38, 38, 38))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton3)
                    .addComponent(jButton2))
                .addContainerGap())
        );

        jMenu1.setText("Archivo");

        jMenuItem1.setText("Analizar");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuItem2.setText("Limpiar");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);
        jMenu1.add(jSeparator1);

        jMenuItem3.setText("Salir");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Acerca de...");

        jMenuItem4.setText("Información");
        jMenuItem4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jMenuItem4MouseClicked(evt);
            }
        });
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem4);

        jMenuItem5.setText("Autores");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem5);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        // TODO add your handling code here:
            JOptionPane.showMessageDialog(this," ** Algoritmos Genéticos - Regresión Simbólica ** \n\nVersion 1.0\n \n IDE: NetBeans 6.8\n\n Plataforma: Java 1.6 \n\nUNAM - Facultad de Ingeniería","Acerca de...",JOptionPane.INFORMATION_MESSAGE);
            
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuItem4MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem4MouseClicked

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
               textField1.setText("");
               textField2.setText("");
               textField3.setText("");
               textField4.setText("");
               textField5.setText("");
               textField6.setText("");
               textField7.setText("");
               textField8.setText("");
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
         textField1.setText("");
               textField2.setText("");
               textField3.setText("");
               textField4.setText("");
               textField5.setText("");
               textField6.setText("");
               textField7.setText("");
               textField8.setText("");
             
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        System.exit(1);
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        // TODO add your handling code here:
        System.exit(1);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:

        Validacion valida=new Validacion();
        if(valida.validarExpresiones(textField1.getText(),textField2.getText(),textField3.getText(),textField4.getText(),textField6.getText(),textField7.getText(),textField8.getText(),textField5.getText()))
        {
        int cabezas=Integer.parseInt(textField1.getText());
        int terminales=Integer.parseInt(textField2.getText());
        double probOper=Double.parseDouble(textField3.getText());

        int poblacion=Integer.parseInt(textField6.getText());
        int generacion=Integer.parseInt(textField4.getText());
        double cruza=Double.parseDouble(textField7.getText());
        double mutacion=Double.parseDouble(textField8.getText());
        double porEli=Double.parseDouble(textField5.getText());
        
        int repeticiones=Integer.parseInt(jSpinner1.getValue().toString());
            System.out.println(repeticiones);

        double x[] =
            {
                -2.8577, -2.8533, -2.1226, -1.8784, -1.3373, -1.278, -0.7809, -0.7196, -0.38318, -0.1837, -0.1406, 0.0253, 0.0621, 0.5572, 0.6630, 0.9391, 0.9413, 1.4329, 1.4348, 1.4531, 1.4964, 1.5106, 1.6081, 1.6676, 1.7334, 2.0301, 2.2076, 2.2206, 2.5794, 2.6919, 2.9618, 3.6405, 4.0368, 4.0847, 4.1335, 4.1812, 4.2198, 4.2406, 4.5948, 4.8386, 5.0452, 5.1621, 5.2886, 5.5184, 6.0282, 6.3290, 6.4976, 6.6882, 6.7709, 6.8616
            };
            double y[] =
            {
                12.5108, 12.6057, 9.6063, 7.1904, 2.4157, 1.9671, -1.0743, -1.3543, -2.4974, -2.845, -2.8885, -0.9478, -0.9367, 0.1179, 0.561, 2.0746, 2.0888, 6.0671, 6.086, 6.2655, 6.7014, 6.8468, 7.8851, 8.5533, 9.3218, 13.216, 15.9383, 16.1525, 23.2309, 26.2879, 40.98, 29.164, 39.8053, 40.9746, 42.1587, 43.3093, 44.2364, 44.7361, 53.2323, 59.132, 64.1467, 66.9617, 69.9539, 75.0719, 75.2065, 247.6863, 145.9792, 139.4597, 140.0652, 141.6499
            };
        double aleatorio = Math.random();
        EvaluadorCromosomas evaluador = new EvaluadorCromosomas(aleatorio, x, y);
        GeneradorCromosomas generador = new GeneradorCromosomas(cabezas, terminales, probOper);
        AlgoritmoGenetico genetico = new AlgoritmoGenetico(generador, evaluador, poblacion, generacion, cruza, mutacion, porEli);
        Cromosoma solucion = null;
        for (int i = 0; i < repeticiones; i++)
        {
            Cromosoma tmp = genetico.ejecutar();
            if(solucion == null)
            {
                solucion = tmp;
            }
            if(tmp.getEvaluacion() < solucion.getEvaluacion())
                solucion = tmp;
        }
        if(solucion == null)
            return;
        jTextArea1.setText(genetico.getSb().toString());
        jTextArea1.append("\n\n\nNumero Aleatorio : " + aleatorio);
        jTextArea1.append("\n\nEvaluacion mejor individuo: " + solucion.getEvaluacion());
        jTextArea1.append("\n\nExpresion mejor invidivuo: " + solucion.getExpresion());
        jTextArea1.append("\n\nRecorrido en orden del mejor individuo: " + solucion.getArbol().enOrden());
        
        
        System.out.println("Numero Aleatorio : " + aleatorio);
        System.out.println("Evaluacion mejor individuo: " + solucion.getEvaluacion());
        System.out.println("Expresion mejor invidivuo: " + solucion.getExpresion());
        System.out.println("Recorrido en orden del mejor individuo: " + solucion.getArbol().enOrden());

        Grafica muestra = new Grafica();
        muestra.muestraGraf(evaluador.getX(), evaluador.getY(), evaluador.getX(), evaluador.obtenerPuntos(solucion), evaluador.getX().length, "Valores Originales", "Valores resultantes");
        ArbolExpresionBinario arbol=solucion.getArbol();
        arbol.profundidadMaxima();
        new Dibuja(arbol);
        

        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        Validacion valida=new Validacion();
        if(valida.validarExpresiones(textField1.getText(),textField2.getText(),textField3.getText(),textField4.getText(),textField6.getText(),textField7.getText(),textField8.getText(),textField5.getText()))
        {

        int cabezas=Integer.parseInt(textField1.getText());
        int terminales=Integer.parseInt(textField2.getText());
        double probOper=Double.parseDouble(textField3.getText());

        int poblacion=Integer.parseInt(textField4.getText());
        int generacion=Integer.parseInt(textField6.getText());
        double cruza=Double.parseDouble(textField7.getText());
        double mutacion=Double.parseDouble(textField8.getText());
        double porEli=Double.parseDouble(textField5.getText());

       int repeticiones=Integer.parseInt(jSpinner1.getValue().toString());
       if(repeticiones == 0)
           return;

         double x[] =
            {
                -2.8577, -2.8533, -2.1226, -1.8784, -1.3373, -1.278, -0.7809, -0.7196, -0.38318, -0.1837, -0.1406, 0.0253, 0.0621, 0.5572, 0.6630, 0.9391, 0.9413, 1.4329, 1.4348, 1.4531, 1.4964, 1.5106, 1.6081, 1.6676, 1.7334, 2.0301, 2.2076, 2.2206, 2.5794, 2.6919, 2.9618, 3.6405, 4.0368, 4.0847, 4.1335, 4.1812, 4.2198, 4.2406, 4.5948, 4.8386, 5.0452, 5.1621, 5.2886, 5.5184, 6.0282, 6.3290, 6.4976, 6.6882, 6.7709, 6.8616
            };
            double y[] =
            {
                12.5108, 12.6057, 9.6063, 7.1904, 2.4157, 1.9671, -1.0743, -1.3543, -2.4974, -2.845, -2.8885, -0.9478, -0.9367, 0.1179, 0.561, 2.0746, 2.0888, 6.0671, 6.086, 6.2655, 6.7014, 6.8468, 7.8851, 8.5533, 9.3218, 13.216, 15.9383, 16.1525, 23.2309, 26.2879, 40.98, 29.164, 39.8053, 40.9746, 42.1587, 43.3093, 44.2364, 44.7361, 53.2323, 59.132, 64.1467, 66.9617, 69.9539, 75.0719, 75.2065, 247.6863, 145.9792, 139.4597, 140.0652, 141.6499
            };
        double aleatorio = Math.random();
        EvaluadorCromosomas evaluador = new EvaluadorCromosomas(aleatorio, x, y);
        GeneradorCromosomas generador = new GeneradorCromosomas(cabezas, terminales, probOper);
        AlgoritmoGenetico genetico = new AlgoritmoGenetico(generador, evaluador, poblacion, generacion, cruza, mutacion, porEli);
        Cromosoma solucion = genetico.ejecutar();
        for (int i = 0; i < repeticiones; i++)
        {
            Cromosoma tmp = genetico.ejecutar();
            if(tmp.getEvaluacion() < solucion.getEvaluacion())
                solucion = tmp;
        }
        System.out.println(genetico.getSb());
        jTextArea1.setText(genetico.getSb().toString());
        jTextArea1.append("\nNumero Aleatorio : " + aleatorio);
        jTextArea1.append("\n\nEvaluacion mejor individuo: " + solucion.getEvaluacion());
        jTextArea1.append("\n\nExpresion mejor invidivuo: " + solucion.getExpresion());
        jTextArea1.append("\n\nRecorrido en orden del mejor individuo: " + solucion.getArbol().enOrden());


        System.out.println("Numero Aleatorio : " + aleatorio);
        System.out.println("Evaluacion mejor individuo: " + solucion.getEvaluacion());
        System.out.println("Expresion mejor invidivuo: " + solucion.getExpresion());
        System.out.println("Recorrido en orden del mejor individuo: " + solucion.getArbol().enOrden());

        Grafica muestra = new Grafica();
        muestra.muestraGraf(evaluador.getX(), evaluador.getY(), evaluador.getX(), evaluador.obtenerPuntos(solucion), evaluador.getX().length, "Valores Originales", "Valores resultantes");
        ArbolExpresionBinario arbol=solucion.getArbol();
        arbol.profundidadMaxima();
        DibujaArbol dibujo=new DibujaArbol(arbol);
        dibujo.setVisible(true);
       }
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(this,"Creado por:\nJuan Fco. Navarrete\nJorge Angel Hernandez\nSaraí Tinoco","créditos",JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Interfaz().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSpinner jSpinner1;
    private javax.swing.JTextArea jTextArea1;
    private java.awt.Label label1;
    private java.awt.Label label12;
    private java.awt.Label label2;
    private java.awt.Label label3;
    private java.awt.Label label4;
    private java.awt.Label label5;
    private java.awt.Label label7;
    private java.awt.Label label8;
    private java.awt.Label label9;
    private java.awt.TextField textField1;
    private java.awt.TextField textField2;
    private java.awt.TextField textField3;
    private java.awt.TextField textField4;
    private java.awt.TextField textField5;
    private java.awt.TextField textField6;
    private java.awt.TextField textField7;
    private java.awt.TextField textField8;
    // End of variables declaration//GEN-END:variables

}
